﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Skynet.WebFoundation.Views.MachineMgm;
using Microsoft.Practices.Unity;
using System.Text;

namespace Skynet.WebSite.Support
{
    public partial class MachineMgmView : Infrastructure.Web.Views.Page, IMachineMgmView
    {
        private MachineMgmPresenter _Presenter;
        [Dependency]
        public MachineMgmPresenter Presenter
        {
            get { return _Presenter; }
            set
            {
                _Presenter = value;
                this._Presenter.View = this;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
                this.Presenter.OnViewInitialized();
            this.Presenter.OnViewLoaded();         
   
        }

        public string decryptionKey
        {
            set { this.txtdecryptionKey.Text = value; }
        }

        public string validationKey
        {
            set { this.txtValidationKey.Text = value; }
        }

        public string validation
        {
            set { this.txtValidation.Text = value; }
        }


        public string decryption
        {
            set { this.txtDecryption.Text = value; }
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            this.Presenter.ProtectSecureSetting();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            this.ViewState["testvalue"] = this.txtSave.Text;
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            this.txtLoad.Text= this.ViewState["testvalue"] as string;
        }
        protected void lbViewValidState_Click(object sender, EventArgs e)
        {
            this.txtViewStateView.Text =  Encoding.UTF8.GetString(Convert.FromBase64String(this.txtViewStateValid.Text));
        }

        protected void btnEncryptConnectionString_Click(object sender, EventArgs e)
        {
            this.Presenter.EncryptConnectionString();
        }

        protected void btnDecryptConnectionString_Click(object sender, EventArgs e)
        {
            this.Presenter.DecryptConnectionString();
        }
    }
}